package com.example.tests;

import com.example.fw.Folders;
import org.testng.annotations.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;

/**
 * Created with IntelliJ IDEA.
 * User: raimbek
 * Date: 14.04.13
 * Time: 12:42
 */
public class TestFolderRemoval extends TestBase {

    @Test
    public void testFolderRemove1() {
        Folders oldFolders = app.getFolderHelper().getFolders();
        Integer index = app.getFolderHelper().randomRemoveFolder();
        Folders newFolders = app.getFolderHelper().getFolders();

        if (index != null) {
            assertThat(newFolders, equalTo(oldFolders.withRemoved(index)));
        } else {
            System.out.println("No folders to delete");
        }
    }

    @Test
    public void testFolderRemove2() {
        String folder = "folder-" + System.currentTimeMillis();

        Folders oldFolders = app.getFolderHelper().getFolders();
        app.getFolderHelper().createFolder(folder);
        app.getFolderHelper().removeFolder(folder);
        Folders newFolders = app.getFolderHelper().getFolders();

        assertThat(newFolders, equalTo(oldFolders));
    }

}
